package com.geeksaga.dao.ibatis.oracle;

import java.util.List;


import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.geeksaga.dao.CategoryDao;
import com.geeksaga.dao.ibatis.BaseIBatisDao;
import com.geeksaga.domain.SagaCategory;

/**
 * @author newbie
 * @since 0.1
 */
@Repository
public class CategoryDaoImpl extends BaseIBatisDao implements CategoryDao {

    /* (non-Javadoc)
     * @see com.geeksaga.dao.CategoryDao#add(com.geeksaga.domain.SagaCategory)
     */
    public SagaCategory add(SagaCategory category) throws DataAccessException {
        return (SagaCategory) getSqlMapClientTemplate().queryForObject("CATEGORY.add", category);
    }
    
    /* (non-Javadoc)
     * @see com.geeksaga.dao.CategoryDao#list()
     */
    @SuppressWarnings("unchecked")
    public List<SagaCategory> list() throws DataAccessException {
        return (List<SagaCategory>) getSqlMapClientTemplate().queryForList("CATEGORY.list");
    }
    
    /* (non-Javadoc)
     * @see com.geeksaga.dao.CategoryDao#findList(java.lang.String)
     */
    @SuppressWarnings("unchecked")
    public List<SagaCategory> findList(String targetId) throws DataAccessException {
        return (List<SagaCategory>) getSqlMapClientTemplate().queryForList("CATEGORY.findList", targetId);
    }
}